package com.wanmait.server.Shiro;

import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @ClassName UserRealm
 * @Author 蝶影
 * @Date 2020/12/821:04
 * @Version 1.0
 * 用于用户的登陆和授权
 **/
@Component
public class UserRealm extends AuthorizingRealm{
    //日志
    private static final Logger log= LoggerFactory.getLogger(UserRealm.class);
    @Override
    protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) {

        return null;
    }

    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
        UsernamePasswordToken token= (UsernamePasswordToken) authenticationToken;
        log.info("用户名是{} 密码是{}",token.getUsername(),String.valueOf(token.getPassword()));
        return null;
    }
}
